package com.competitions.easydubbing.entity;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;

/**
 * @author Mapler
 * @since 2021-5-20
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Result implements Serializable {

    private static final long serialVersionUID = 1L;

    protected Object data;

    protected String msg;

    private Result(String msg, Object data) {
        this.msg = msg;
        this.data = data;
    }


    public static Result ok(String msg, Object data) {
        return new Result(msg, data);
    }

    public static Result ok(Object data) {
        return ok(null,data);
    }

    public static Result ok() {
        return ok("ok", null);
    }

    public static Result error(String msg) {
        return new Result(msg, null);
    }
}
